#!C:/perl/bin/perl
# WWWDENY - Simple Remote Host Identification & Rejection or Accept
# Created by Brock Eastman - Network Administrator - 2INTERACTIVE.COM
# info@2interactive.com
# Created on: 3/2/00       Last Modified on: 3/6/00
# Version 1.0
# Check http://www.2interactive.com/scripts/wwwDENY for the newest version.
# This script should be used as a server side include.
# <!--#exec cgi="http://your.host.xxx/cgi-bin/remote_host.pl"-->
# Or you can call it as the script itself. http://2interactive.com/index.cgi
###NOTE!!! PLEASE READ THIS##
##THE $ADDRESS_DENY is the single ip address or block of ip addresses you want to deny.
##lets say you wanted to block all ip addresses from 199.5.* .
## All you have to do is put in 199.5.* - it's that simple.
## The information below is what I used the script for.
## We did not want volkswagen of america to see our main page, so we just denied their ip block.
## This was about a boycott - VWOA is doing very unethical things =( - check out www.vwmagazine.com/vwoa


########################################################
###################CONFIG VARS##########################
########################################################
$WRITE_PAGE="data.txt";
$ADDRESS_DENY="199.5.*";
###########################################################################################
#########NOTE : WRITE_PAGE is the file you want the script to log ip addresses to.#########
#########THIS WILL LET YOU KNOW WHO HAS BEEN HITTING THE SITE - CHMOD data.txt to 777######
###########################################################################################


#########################################################
##################DO NO TOUCH BELOW #####################
#########################################################
##REMOTE HOST ENV METHOD##
$ADDRESS=$ENV{'REMOTE_ADDR'};

####WRITE TO FILE####
sub write_entry {

open(FILE,">>$WRITE_PAGE");
print FILE "$ADDRESS\n";
close(FILE);

}

####GET HOST ADDRESS AND ANALYZE####
if($ADDRESS=~ /$ADDRESS_DENY/)
{

&write_entry;
#########################################################
#############YOU MAY EDIT THIS SECTION - BE CAREFUL######
#########################################################

print "Content-type: text/html\n\n";
print "Hello VWoA - You are not welcome to view this page\n";
print "<BR>We have logged your IP address as: $ADDRESS\n";
print "<BR>Have a nice day.\n";
print "<P><a href=data.txt>Here is a list of IP addresses attempting to access this page from VWOA. \n";
print "</a><P><a href=guestbook.html>CLICK HERE TO SEE WHAT MANY DISCONTENT VW ENTHUSIASTS HAVE HAD TO SAY ABOUT YOUR ACTIONS.
\n";
}

else {


print "Content-type: text/html\n\n";

print "Hello and Welcome to the Kernel foo-bar Page from <B>$ENV{'REMOTE_ADDR'}</B>\n";
#print "<BR> Volkswagen of America has been visiting this site. \n";
#print "<P>You can view how many times they have been here by going to <a href=data.txt>DATA FILE</a> \n";
#print "<BR>VWOA IS NOT ALLOWED TO VIEW THIS SITE, AND OUR SERVER IDENTIFIES THEM WITH NO ACCESS. \n";
#print "<P><BIG><a href=main.html>ENTER THE OFFICIAL STOP VWOA SITE ! UPDATED 3/6/00</a> \n";
print "<A HREF =\"mailto:mina.ramses\@gmail.com\"><BR>Contact for notes</BR></A>\n";
print "<A HREF =\"http:\//minaramses.homelinux.org\"><BR>HOME</BR></A>";


}
